package untiring07_HelloJDBC;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Image;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.awt.Toolkit;

//화면크기 800x600
//파일(F)->새성정(N)|종료(X)
//보기(V)->전체 성적보기(L)
//도움말(H)->도움말항목(H)|프로그램정보(A)
public class SungJukMainFrame extends JFrame {

	private JPanel contentPane;
	private static SungJukMainFrame frame;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frame = new SungJukMainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	
	/**
	 * Create the frame.
	 */
	public SungJukMainFrame() {
		setIconImage(Toolkit.getDefaultToolkit().getImage(SungJukMainFrame.class.getResource("/images/icon1.png")));
		setTitle("성적처리 프로젝트 V0.1");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 600);
		getContentPane().setLayout(new BorderLayout());
		//이미지 객체 생성
		//이미지에 대한 확대/축소 작업을 위해 먼저 이미지를 메모리로 불러들여야 함
		// 이때 사용하는 클래스가 BufferedImage임
		BufferedImage image=null;
		try {
			image = ImageIO.read(getClass().getResource("/images/suji02.jpg"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		//이미지를 지정한 크기로 축소
		Image resizeimg = image.getScaledInstance(800, 520, Image.SCALE_SMOOTH);
		//JLabel에 이미지 지정후 JFrame에 추가
		getContentPane().add(new JLabel(new ImageIcon(resizeimg)),BorderLayout.CENTER);
		
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);

		JMenu mnFile = new JMenu("파일(F)");
		mnFile.setIcon(new ImageIcon(SungJukMainFrame.class
				.getResource("/images/KakaoTalk_d565b071a1ff9e89.png")));
		menuBar.add(mnFile);

		JMenuItem miNew = new JMenuItem("새성적...(N)");
		miNew.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new SungJUkNewData(frame);
			}
		});
		miNew.setIcon(new ImageIcon(SungJukMainFrame.class
				.getResource("/images/KakaoTalk_ef6e71492e946bb2.png")));
		mnFile.add(miNew);

		JSeparator separator = new JSeparator();
		mnFile.add(separator);

		JMenuItem miExit = new JMenuItem("종료(X)");
		miExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		miExit.setIcon(new ImageIcon(SungJukMainFrame.class
				.getResource("/images/KakaoTalk_8f42d966f7a08613.png")));
		mnFile.add(miExit);

		JMenu mnView = new JMenu("보기(V)");
		mnView.setIcon(new ImageIcon(SungJukMainFrame.class
				.getResource("/images/KakaoTalk_59580e5fccccaa44.png")));
		menuBar.add(mnView);

		JMenuItem miList = new JMenuItem("전체 성적보기(L)");
		miList.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new SungJukShowList(frame);
			}
		});
		miList.setIcon(new ImageIcon(SungJukMainFrame.class
				.getResource("/images/SUJI.png")));
		mnView.add(miList);

		JMenu mnHelp = new JMenu("도움말(H)");
		mnHelp.setIcon(new ImageIcon(SungJukMainFrame.class
				.getResource("/images/KakaoTalk_1dfe3b2a425a1269.png")));
		menuBar.add(mnHelp);

		JMenuItem miHelp = new JMenuItem("도움말 항목(H)");
		miHelp.setIcon(new ImageIcon(SungJukMainFrame.class
				.getResource("/images/jinsu1.png")));
		mnHelp.add(miHelp);

		JSeparator separator_2 = new JSeparator();
		mnHelp.add(separator_2);

		JMenuItem miAbout = new JMenuItem("프로그램 정보(A)");
		miAbout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new SungJukAboutDialog(frame);

			}
		});
		miAbout.setIcon(new ImageIcon(SungJukMainFrame.class
				.getResource("/images/KakaoTalk_3f822cbd74d3ef85.png")));
		mnHelp.add(miAbout);
		setVisible(true);
	}
}
